#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const double alpha = 0.7;

int n, m, num, K;
struct Node {
  int x, y, z, cnt;
  bool operator<(const Node &b) const {
    if (z != b.z) return z < b.z;
    if (x != b.x) return x < b.x;
    return y < b.y;
  }
} a[N];
struct KD {
  int sz, cnt;
  int ch[2];
  int v[2];
  int L[2], U[2];
} tr[N];
#define sz(p) tr[p].sz
#define cnt(p) tr[p].cnt
#define lc(p) tr[p].ch[0]
#define rc(p) tr[p].ch[1]
#define v(p, k) tr[p].v[k]
#define L(p, k) tr[p].L[k]
#define U(p, k) tr[p].U[k]
int root, cur;
int g[N], top;
int ans[N];

bool cmp(int x, int y) { return v(x, K) < v(y, K); }
void pushup(int p) {
  sz(p) = sz(lc(p)) + sz(rc(p)) + cnt(p);
  rep(k, 0, 1) {
    L(p, k) = U(p, k) = v(p, k);
    if (lc(p)) {
      L(p, k) = min(L(p, k), L(lc(p), k));
      U(p, k) = max(U(p, k), U(lc(p), k));
    }
    if (rc(p)) {
      L(p, k) = min(L(p, k), L(rc(p), k));
      U(p, k) = max(U(p, k), U(rc(p), k));
    }
  }
}
int build(int k, int l, int r) {
  if (l > r) return 0;
  int m = (l + r) >> 1;
  K = k;
  nth_element(g + l, g + m, g + r + 1, cmp);
  lc(g[m]) = build(k ^ 1, l, m - 1);
  rc(g[m]) = build(k ^ 1, m + 1, r);
  pushup(g[m]);
  return g[m];
}
void dfs(int p) {
  if (!p) return;
  g[++top] = p;
  dfs(lc(p)), dfs(rc(p));
}
void check(int k, int &p) {
  if (alpha * sz(p) < max(sz(lc(p)), sz(rc(p))))
    top = 0, dfs(p), p = build(k, 1, top);
}
void insert(int k, int &p) {
  if (!p) {
    p = cur;
    pushup(p);
    return;
  }
  if (v(cur, k) <= v(p, k))
    insert(k ^ 1, lc(p));
  else
    insert(k ^ 1, rc(p));
  pushup(p);
  check(k, p);
}
int query(int p) {
  if (!p) return 0;
  rep(k, 0, 1) if (v(cur, k) < L(p, k)) return 0;
  if (U(p, 0) <= v(cur, 0) && U(p, 1) <= v(cur, 1)) return sz(p);
  int res = 0;
  if (v(p, 0) <= v(cur, 0) && v(p, 1) <= v(cur, 1)) res += cnt(p);
  return res + query(lc(p)) + query(rc(p));
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) {
    cin >> a[i].x >> a[i].y >> a[i].z;
    a[i].cnt = 1;
  }
  sort(a + 1, a + n + 1);
  num = 0;
  rep(i, 1, n) {
    if (a[num].x == a[i].x && a[num].y == a[i].y && a[num].z == a[i].z)
      a[num].cnt++;
    else
      a[++num] = a[i];
  }
  for (cur = 1; cur <= num; cur++) {
    v(cur, 0) = a[cur].x, v(cur, 1) = a[cur].y, cnt(cur) = a[cur].cnt;
    insert(0, root);
    int cnt = query(root) - 1;
    ans[cnt] += a[cur].cnt;
  }
  rep(i, 0, n - 1) cout << ans[i] << endl;
  return 0;
}